************
*Intrastate*
************

use "Datasets/124920_1ucdp-prio-_2015.dta", clear

drop if type == 1
drop if type == 2

gen conflict = .
replace conflict = 1 if type > 0
egen sumAllConflict=sum(conflict),by(year)
*collapse (sum) conflict, by (year)

gen war = .
replace war = 1 if intensitylevel == 2
egen sumwar=sum(war),by(year)
*collapse (sum) war, by (year)

rename sidea SideA
rename sideb SideB


**************************
*** 1. Muslim countries***
**************************


gen MuslimDum = .

lab var MuslimDum "Countries with Muslim majority ( > 50 percent)"

*Afghanistan
replace MuslimDum = 1 if location == "Afghanistan"

*Algeria
replace MuslimDum = 1 if location == "Algeria"

*Azerbaijan
replace MuslimDum = 1 if location == "Azerbaijan"

*Bangladesh
replace MuslimDum = 1 if location == "Bangladesh"

*Bosnia-Herzegovina
*replace MuslimShare = 45.2 if location == "Bosnia-Herzegovina"
*replace MuslimDum = 1 if location == "Bosnia-Herzegovina"

*Brunei
replace MuslimDum = 1 if location == "Brunei"

*Burkina Faso
replace MuslimDum = 1 if location == "Burkina Faso"

*Chad
replace MuslimDum = 1 if location == "Chad"

*Comoros
replace MuslimDum = 1 if location == "Comoros"

*Djibouti
replace MuslimDum = 1 if location == "Djibouti"

*Egypt
replace MuslimDum = 1 if location == "Egypt"

*Gambia
replace MuslimDum = 1 if location == "Gambia"

*Guinea 
replace MuslimDum = 1 if location == "Guinea"

*Guinea-Bissau
*!!OBSOBS!!!*
replace MuslimDum = 1 if location == "Guinea-Bissau"


*Indonesia
replace MuslimDum = 1 if location == "Indonesia"

*Iran
replace MuslimDum = 1 if location == "Iran"

*Iraq
replace MuslimDum = 1 if location == "Iraq"

*Israel
*replace MuslimShare = 18.6 if location == "Israel"
*replace MuslimDum = 0 if location == "Israel"

*Lebanon
replace MuslimDum = 1 if location == "Lebanon"

*Libya
replace MuslimDum = 1 if location == "Libya"

*Malaysia
replace MuslimDum = 1 if location == "Malaysia"

*Mali
replace MuslimDum = 1 if location == "Mali"

*Mauritania
replace MuslimDum = 1 if location == "Mauritania"

*Morocco
replace MuslimDum = 1 if location == "Morocco"

*Niger
replace MuslimDum = 1 if location == "Niger"

*Nigeria
*replace MuslimShare = 48.8 if SideB == "Jama'atu Ahlis Sunna Lidda'awati wal-Jihad "
*replace MuslimShare = 48.8 if SideB == "Ahlul Sunnah Jamaa"
*replace MuslimDum = 0 if SideB == "Jama'atu Ahlis Sunna Lidda'awati wal-Jihad "
*replace MuslimDum = 0 if SideB == "Ahlul Sunnah Jamaa"

*Oman
replace MuslimDum = 1 if location == "Oman"

*Pakistan
replace MuslimDum = 1 if location == "Pakistan"

*Russia
*replace MuslimShare = 10.0 if SideB == "Wahhabi movement of the Buinaksk district"
*replace MuslimDum = 0 if SideB == "Wahhabi movement of the Buinaksk district"

*Saudi Arabia
replace MuslimDum = 1 if location == "Saudi Arabia"

*Senegal
replace MuslimDum = 1 if location == "Senegal"

*Sierra Leone
replace MuslimDum = 1 if location == "Sierra Leone"

*Somalia
replace MuslimDum = 1 if location == "Somalia"

*Sudan
replace MuslimDum = 1 if location == "Sudan"

*Syria
replace MuslimDum = 1 if location == "Syria"

*Tajikistan
replace MuslimDum = 1 if location == "Tajikistan"

*Tunisia
replace MuslimDum = 1 if location == "Tunisia"

*Turkey
replace MuslimDum = 1 if location == "Turkey"

*US
*replace MuslimShare = 0.9 if SideB == "al-Qaida "
*replace MuslimDum = 0 if SideB == "al-Qaida "

*Uzbekistan
replace MuslimDum = 1 if location == "Uzbekistan"

*Yemen
replace MuslimDum = 1 if inlist(location, "North Yemen ","North Yemen, South Yemen","South Yemen","Yemen","Yemen (North Yemen)")

egen sumMuslimDum=sum(MuslimDum),by(year)

**************
***Islamist***
**************

gen islamist = .

lab var islamist "Rebel groups with Islamist orientation"
*Afghanistan
replace islamist = 1 if location == "Afghanistan"
replace islamist = . if SideB == "UIFSA"
*Algeria
replace islamist = 1 if location == "Algeria" 
*Chad
replace islamist = 1 if inlist(SideB, "Islamic Legion, MOSANAT, Revolutionary Forces of 1 April ","Islamic Legion, MPS")
*Egypt
replace islamist = 1 if location == "Egypt" 
*Eritrea
replace islamist = 1 if SideB == "EIJM - AS"
*Ethiopia
replace islamist = 1 if inlist(SideB, "AIAI","AIAI, ONLF")
*India (some of these groups were islamist)
replace islamist = 1 if SideB == "Kashmir insurgents"
replace islamist = 1 if SideB == "PULF"
*Indonesia
replace islamist = 1 if inlist(SideB, "Darul Islam ","Darul Islam, Permesta movement, PRRI")
replace islamist = 1 if inlist(SideB, "Darul Islam","Darul Islam, Permesta Movement, PRRI")
replace islamist = 1 if SideB == "GAM"
*Iran
replace islamist = 1 if inlist(SideB, "Jondullah","Jondullah, PJAK")
*Iraq
replace islamist = 1 if inlist(SideB, "Al-Mahdi Army, Ansar al-Islam, IS","Ansar al-Islam, IS, RJF","al-Mahdi Army, Ansar al-Islam, IS, RJF","al-Mahdi Army, IS","IS","Ansar al-Islam, IS","IS")
replace islamist = 1 if SideB == "SCIRI"
*Israel
replace islamist = 1 if inlist(SideB, "Hezbollah","Hamas","PIJ","Fatah, Hamas, PFLP, PNA","AMB, Fatah, Hamas, PIJ, PNA","AMB, Hamas, PIJ","Fatah, Hamas, PIJ","Fatah, Hamas, PIJ, PRC","Hamas, PIJ")
*Lebanon
replace islamist = 1 if SideB == "IS"
*Mali
replace islamist = 1 if inlist(SideB, "al-Murabitun, AQIM","AQIM","Ansar Dine, Military faction (Red Berets)","Ansar Dine, AQIM, MUJAO, Signed-in-Blood Battalion")
*Mauritania
replace islamist = 1 if SideB == "AQIM"
*Nigeria
replace islamist = 1 if SideB == "Jama'atu Ahlis Sunna Lidda'awati wal-Jihad "
replace islamist = 1 if SideB == "Jama'atu Ahlis Sunna Lidda'awati wal-Jihad"
replace islamist = 1 if SideB == "Ahlul Sunnah Jamaa"
*Pakistan
replace islamist = 1 if inlist(SideB, "TNSM","TTP","Lashkar-e-Islam, TTP, TTP - TA","TTP, Lashkar-e-Islam","TTP, TTP-TA, Lashkar-e-Islam","Lashkar-e-Islam, TTP","Jamaat-ul-Ahrar, Lashkar-e-Islam, TTP, IMU")
*Philippines
replace islamist = 1 if inlist(SideB, "MILF, MNLF","ASG, MNLF","ASG, MILF","ASG","MILF","ASG, MILF, MNLF - NM","ASG, MILF, MNLF - HM","ASG, BIFM","ASG, BIFM, MNLF - NM")
*Russia
replace islamist = 1 if inlist(SideB, "Wahhabi movement of the Buinaksk district","Forces of the Caucasus Emirate")
*Saudi Arabia
replace islamist = 1 if SideB == "JSM"
*Somalia
replace islamist = 1 if inlist(SideB, "ARS/UIC","Al-Shabaab, ARS/UIC, Harakat Ras Kamboni","Al-Shabaab, Hizbul-Islam","Al-Shabaab","Al-Shabaab, Hizbul Islam","Al-Shabaab, ARS/UIC")
*Sudan
replace islamist = 1 if SideB == "Islamic Charter Front"
*Syria (some of these groups were islamist)
replace islamist = 1 if SideB == "FSA, Jabhat al-Nusra li al-Sham"
replace islamist = 1 if location == "Syria" & SideB == "Muslim Brotherhood"
replace islamist = 1 if SideB == "Syrian insurgents"
*Tajikistan
*The Islamic Renaissance Party (IPR) was apart of UTO, amongst other non-islamist groups.
replace islamist = 1 if inlist(SideB, "UTO","Forces of Khudoberdiyev, UTO","IMU")
*Thailand
replace islamist = 1 if SideB == "Patani insurgents"
*Uganda
replace islamist = 1 if SideB == "ADF, LRA"
replace islamist = 1 if SideB == "ADF, LRA, WNBF"
replace islamist = 1 if SideB == "ADF, LRA, UNRF II"

*US 
replace islamist = 1 if SideB == "al-Qaida "
replace islamist = 1 if SideB == "al-Qaida"
*Uzbekistan
replace islamist = 1 if inlist(SideB, "IMU","JIG")
*Yemen 
replace islamist = 1 if inlist(SideB, "AQAP","AQAP, Ansarallah")

egen sumislamist=sum(islamist),by(year)

save "Datasets/muslim_conflicts_2015.dta", replace
